<template>
  <svg :class="svgClass" aria-hidden="true">
      <use :xlink:href="iconClassName"></use>
  </svg>
</template>

<script setup>
import { computed } from 'vue'

const props = defineProps({
  // 添加自定义类名
  className: {
      type: String,
      default: ''
  },
  // iconfont中的名字 
  iconName: {
      type: String,
      required: true
  }
})

const svgClass = computed(() => {
  if (props.className) {
      return `svg-icon ${ props.className }`
  } else {
      return 'svg-icon'
  }
})
const iconClassName = computed(() => `#${ props.iconName }`)
</script>

<style scoped>
.svg-icon {
  width: 1.5em;
  height: 1.5em;
}
.weather {
  width: 3em;
  height: 3em;
}
.small {
  width: 1.2em;
  height: 1.2em;
}
</style>